//
//  NoteList.m
//  Assignment3Temp
//
//  Created by zslocum on 3/9/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "NoteList.h"


@implementation NoteList
- (NoteList*) setupList {
	self = [super init];
	if(self)
	{
		noteArray = [NSMutableArray init];
		titleArray = [NSMutableArray init];
		NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString* documentsDirectory = [paths objectAtIndex:0];
documentsDirectory = [documentsDirectory stringByAppendingPathComponent: @"/notes"]
NSArray* dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];\

for (int x = 0; x < [dirContents count]; x++)
{
	Note* newNote = [Note loadNote: [dirContents objectAtIndex: x]];
	[noteArray addObject: newNote]
	[titleArray addObject: [newNote getTitle]];
}

		//need to load data from disk
	}
	return self;
}
- (NSMutableArray*)getTitles{
	return titleArray;
}
- (Note*)getNote:(int)index {
	return (Note*)[noteArray objectAtIndex:index];
}
- (NSMutableArray*)getAllNotes {
	return noteArray;
}
- (void)addNote: (Note*)n {
	[noteArray addObject:n];
}
- (void)saveAll{
for(int x = 0; x < [noteArray count]; x++){
Node* current = [self getNote: x];
if(![current isDeleted]
{
	[current save];
}
}
}
- (void)deleteAll{
for(int x = 0; x < [noteArray count]; x++){
Node* current = [self getNote: x];
if(![current isDeleted]
{
	[current deleteIt];
}
}
}
@end
